/**
 * 
 */
package com.google.code.jkippt.parser;

import java.io.StringReader;

import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;

/**
 * {@link PageParser} builder.
 * @author Federico De Faveri defaveri@gmail.com
 */
public class PageParserBuilder<T> {

	protected Gson gson;
	protected Class<T> type;

	/**
	 * @param gson
	 * @param type
	 */
	protected PageParserBuilder(Gson gson, Class<T> type) {
		this.gson = gson;
		this.type = type;
	}

	/**
	 * Returns a new {@link PageParser} for the specified page.
	 * @param json the page json.
	 * @return the page parser.
	 * @throws ParserException
	 */
	public PageParser<T> getParser(String json) throws ParserException
	{
		JsonReader reader = new JsonReader(new StringReader(json));
		PageParser<T> parser = new PageParser<T>(gson, reader, type);
		return parser;
	}


}
